/***********************************************************************
* ******************************************************************** *
* *                                                                  * *
* *   BIOS Selector Shell for Rabbit 4000 CPU based boards.          * *
* *                                                                  * *
* *                                                                  * *
* *    Copyright (c)  1999-2006 Rabbit Semiconductor, Inc.           * *
* *                                                                  * *
* *   Assumes ATMEL compatible flash algorithms.                     * *
* *                                                                  * *
* ******************************************************************** *
***********************************************************************/

#ifndef __BIOS_ALREADY_COMPILED
   #define __BIOS_ALREADY_COMPILED
#else
   #fatal "Cannot compile the BIOS as a user program!"
#endif

#use "SYSIODEFS.LIB"
#use "SYSCONFIG.LIB"    // All user-defined macros for BIOS configuration
#use "BOARDTYPES.LIB"   // board-specific initialization header

// ***** _CLK_DBL_ macro check *****************************************
#if (CPU_ID_MASK(_CPU_ID_) < R4000)
   #fatal "This version of Dynamic C is only supported for RCM4XXX or newer core modules."
#endif

enum OriginType { UNKNOWN_ORG = 0, RCODORG, XCODORG, WCODORG, RVARORG, XVARORG,
                  WVARORG, RCONORG, RESVORG };

typedef struct {
   char type;
   char flags;                //
   unsigned long  paddr;      // Physical address
   unsigned    laddr;         // Logical address
   unsigned long  usedbytes;  // Actual number of bytes used or reserved
                              // starting from paddr/laddr
   unsigned long  totalbytes; // Total space allocated
} _sys_mem_origin_t;

// These are defined by the compiler.
extern int _orgtablesize;
extern _sys_mem_origin_t _orgtable[];

#define _cexpr(X) 0+(X)

#use "stdBIOS.c"

#flushlib
#flushlib

#pragma CompileProgram

#flushcompile

#flushlib
#flushlib
#flushlib

#asm
StartUserCode::
#endasm

// NOTE:  The #use "PRECOMPILE.LIB" MUST come after the #pragma CompileProgram.
#use "PRECOMPILE.LIB"